/**
 * 
 */
package com.disys.facade;

import java.util.ArrayList;
import java.util.List;

import com.disys.dao.LdapUsersDAO;
import com.disys.model.LdapUsers;
import com.disys.model.Rec295EmpPayCheck;

/**
 * @author Ubaid Raja
 *
 */
public class LdapUsersFacade {
	private LdapUsersDAO userDAO = new LdapUsersDAO();

	public LdapUsers isAuthorized(String uid) {
		userDAO.beginTransaction();
		LdapUsers user = userDAO.findUserByUID(uid);
		userDAO.closeTransaction();

		//see, if user is not found in the database or if user is in-active.
		if (user == null || (user.getActive().toString().equals("0"))) {
			return null;
		}

		return user;
	}
	
	public List<LdapUsers> findAllLdapUsers(){
		userDAO.beginTransaction();	
		List<LdapUsers> list = userDAO.findAll();
		userDAO.closeTransaction();
		if(list.size() ==0 || list == null){
			return new ArrayList<LdapUsers>();
		}
		return list;
	}
}
